﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace ZoneLine
{
    public abstract class ViewModelBase : ObservableObject
    {

        public event Action<string> OnShowMsg;
        public event Func<string, Task<bool>> OnConfirm;

        public abstract bool Init();

        protected void ShowMsg(string msg)
        {
            try
            {
                OnShowMsg?.Invoke(msg);
            }
            catch (Exception)
            {
            }
        }
        protected async Task<bool> Confirm(string msg)
        {
            if (OnConfirm != null)
            {
                try
                {
                    return await OnConfirm.Invoke(msg);
                }
                catch (Exception)
                {
                }
            }
            return false;
        }


    }
}
